package com.hzy.pms.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hzy.pms.domain.bo.ProductBo;
import com.hzy.pms.domain.vo.ProductVo;
import com.hzy.pms.service.IProductService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 商品信息
 *
 * @author zengxin
 * @date 2023-10-17
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/pms/product")
public class ProductController extends BaseController {

    private final IProductService iProductService;

    /**
     * 查询商品信息列表
     */
    @GetMapping("/list")
    public R<Page<ProductVo>> list(ProductBo bo, Pageable pageQuery) {
        IPage<ProductVo> page = iProductService.queryWebPageList(bo, pageQuery);
        return R.ok(new PageImpl<ProductVo>(page.getRecords(), pageQuery, page.getTotal()));
    }


    /**
     * 获取商品信息详细信息
     *
     * @param id 主键
     */
    @GetMapping("/detail/{id}")
    public R<ProductVo> getInfo(@NotNull(message = "主键不能为空")
                                @PathVariable Long id) {
        return R.ok(iProductService.queryById(id));
    }

}
